/* 
 * File:   FiguraFactoryException.cpp
 * Author: Maximiliano Monzón (82341)
 * 
 * Created on October 4, 2012, 7:47 PM
 */

#include "FiguraFactoryException.h"

#include <cstring>

using namespace TP::Grafica::Componentes;

FiguraFactoryException::FiguraFactoryException(const char* pMessage) {
    
    char* aux;
    
    if (NULL != this->message)
    {    
        aux = new char [strlen(this->message) + strlen(pMessage) + 1];
        aux [0] = '\0';
        strcat (aux, this->message);
        strcat (aux, pMessage);
    }
    else
    {
        aux = new char [strlen(pMessage) + 1];
        aux [0] = '\0';
        strcat (aux, pMessage);
    }
    delete [] this->message;
    this->message = aux;
}

FiguraFactoryException::~FiguraFactoryException() throw (){
    delete [] this->message;
    this->message = NULL;
}

void FiguraFactoryException::expandirMensaje (const char* pMessage) {

    char* aux;
    
    if (NULL != this->message)
    {    
        aux = new char [strlen(this->message) + strlen(pMessage) + 1];
        aux [0] = '\0';
        strcat (aux, pMessage);
        strcat (aux, this->message);
    }
    else
    {
        aux = new char [strlen(pMessage) + 1];
        aux [0] = '\0';
        strcat (aux, pMessage);
    }
    delete [] this->message;
    this->message = aux;

}

const char* FiguraFactoryException::what() const throw (){
    return this->message;
}

